package com.muyu.danmo.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoAssociationType;
import com.muyu.danmo.service.IDanmoAssociationTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 艺术家类型名称Controller
 *
 * @author yangle
 * @date 2024-09-27
 */
@RestController
@RequestMapping("/associaType")
public class DanmoAssociationTypeController extends BaseController
{
    @Autowired
    private IDanmoAssociationTypeService danmoAssociationTypeService;

    /**
     * 查询艺术家类型名称列表
     */
//    @RequiresPermissions("system:type:list")
    @PostMapping("/list")
    public Result<List<DanmoAssociationType>> list(@RequestBody DanmoAssociationType danmoAssociationType)
    {

        List<DanmoAssociationType> list = danmoAssociationTypeService.selectDanmoAssociationTypeList(danmoAssociationType);
        return Result.success(list);
    }

    /**
     * 导出艺术家类型名称列表
     */
//    @RequiresPermissions("system:type:export")
    @Log(title = "艺术家类型名称", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoAssociationType danmoAssociationType)
    {
        List<DanmoAssociationType> list = danmoAssociationTypeService.selectDanmoAssociationTypeList(danmoAssociationType);
        ExcelUtil<DanmoAssociationType> util = new ExcelUtil<DanmoAssociationType>(DanmoAssociationType.class);
        util.exportExcel(response, list, "艺术家类型名称数据");
    }

    /**
     * 获取艺术家类型名称详细信息
     */
//    @RequiresPermissions("system:type:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoAssociationTypeService.selectDanmoAssociationTypeById(id));
    }

    /**
     * 新增艺术家类型名称
     */
//    @RequiresPermissions("system:type:add")
    @Log(title = "艺术家类型名称", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoAssociationType danmoAssociationType)
    {
        return toAjax(danmoAssociationTypeService.insertDanmoAssociationType(danmoAssociationType));
    }

    /**
     * 修改艺术家类型名称
     */
//    @RequiresPermissions("system:type:edit")
    @Log(title = "艺术家类型名称", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoAssociationType danmoAssociationType)
    {
        return toAjax(danmoAssociationTypeService.updateDanmoAssociationType(danmoAssociationType));
    }

    /**
     * 删除艺术家类型名称
     */
//    @RequiresPermissions("system:type:remove")
    @Log(title = "艺术家类型名称", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoAssociationTypeService.deleteDanmoAssociationTypeByIds(ids));
    }
}
